package StringBuilder.exercise;

import java.util.ArrayList;
import java.util.Scanner;

public class Work5 {
    public static void main(String[] args) {
        ArrayList<Student1> Array =new ArrayList<>();
        Insert(Array);
        Insert(Array);
        Insert(Array);
    }

    private static void Insert(ArrayList<Student1> array) {
        Student1 sks=new Student1();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入学生姓名：");
        String name=sc.nextLine();
        System.out.println("请输入年龄：");
        int age=sc.nextInt();
        sks.setName(name);
        sks.setAge(age);
        array.add(sks);
    }
}
class Student1{
    private String name;
    private int age;

    public Student1() {
    }

    public Student1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
